<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATES_PATH;?>/css/member_order.css">
<link href="<?php echo TEMPLATES_PATH;?>/css/btn.css" media="all" rel="stylesheet" type="text/css">
<link href="<?php echo TEMPLATES_PATH;?>/css/checkbox.css" media="all" rel="stylesheet" type="text/css">
<link href="<?php echo TEMPLATES_PATH;?>/css/list.css" media="all" rel="stylesheet" type="text/css">
<div id="mainLayout" style="display:-webkit-box;">
	<div id="mainStay" style="-webkit-box-flex: 1;width: 100%; display:block">
        <div class="s-input-select" style="margin-bottom:10px; margin-top:10px;">
            <select id="state_type">
                <option value="all" <?php echo $_GET['state_type']=='all'?'selected':''; ?>>所有订单</option>
                <option value="order_pay" <?php echo $_GET['state_type']=='order_pay'?'selected':''; ?>>等待付款</option>
                <option value="order_pay_confirm" <?php echo $_GET['state_type']=='order_pay_confirm'?'selected':''; ?>>待卖家收款</option>
                <option value="order_no_shipping" <?php echo $_GET['state_type']=='order_no_shipping'?'selected':''; ?>>等待发货</option>
                <option value="order_shipping" <?php echo $_GET['state_type']=='order_shipping'?'selected':''; ?>>已经发货</option>
                <option value="order_finish" <?php echo $_GET['state_type']=='order_finish'?'selected':''; ?>>已完成</option>
                <option value="order_cancal" <?php echo $_GET['state_type']=='order_cancal'?'selected':''; ?>>已取消</option>
                <option value="order_refer" <?php echo $_GET['state_type']=='order_refer'?'selected':''; ?>>已提交</option>
                <option value="order_confirm" <?php echo $_GET['state_type']=='order_confirm'?'selected':''; ?>>已确认</option>
            </select>
            <div class="s-input-frame">
                <form class="c-form-suggest" id="J_Search" method="get">
                    <input type="hidden" name="act" value="member_order" />
                    <input type="hidden" name="state_type" id="st" value="<?php echo $_GET['state_type']?>" />
                    <div class="s-form-search search-form">
                        <input type="text" name="order_sn" class="J_autocomplete" autocomplete="off" placeholder="订单号" value="<?php echo $_GET['order_sn']; ?>"><button><span></span></button>
                    </div>
                    <div class="c-form-btn">
                        <button class="searchbtn">搜 索</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="wrap">	
            <section class="order-con">
                <?php if(!empty($output['order_array']) && is_array($output['order_array'])){?>
                <ul class="order-list" id="orders_list">
                    <?php foreach($output['order_array'] as $order_id=>$goods_arr){?>
                    <li>
                        <div class="order-box">
                            <!--<div class="order-sn">
                                <table width="100%">
                                    <tr>
                                        <td width="25%" align="right">订&nbsp; 单&nbsp;号：</td>
                                        <td width="80%"><?php echo $goods_arr[0]['order_sn']; ?></td>
                                    </tr>
                                    <tr>
                                        <td align="right">下单时间：</td>
                                        <td><?php echo date("Y-m-d H:i:s",$goods_arr[0]['add_time']); ?></td>
                                    </tr>
                                    <tr>
                                        <td align="right">订单总价：</td>
                                        <td>&yen;<?php echo $goods_arr[0]['order_amount']; ?>&nbsp;&nbsp;
                                            <?php if ($goods_arr[0]['shipping_fee'] > 0){?>
                                            (含<?php echo $goods_arr[0]['shipping_name']?$goods_arr[0]['shipping_name']:'运费';?> &yen;<?php echo $goods_arr[0]['shipping_fee'];?>)
                                            <?php }else{?>
                                            <?php echo '(免运费)';?>
                                            <?php }?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">交易状态：</td>
                                        <td><?php echo $goods_arr[0]['state_info']; ?></td>
                                    </tr>
                                </table>
                            </div>-->
                             <?php if ($goods_arr[0]['order_state'] == 10 && $goods_arr[0]['order_cod'] != 1) { ?>
                             <a href="javascript:void(0);" onclick="selChange(this);" class="checkbox goods-choose-state" data-order_id="<?php echo $goods_arr[0]['order_id']; ?>"></a>
                             <?php }?>
                             <div class="order-width">
                                <p class="border-bottom usr-name">订单编号：<span class="fr"><?php echo $goods_arr[0]['order_sn']; ?></span></p>
                                <p class="border-bottom usr-name">订单总价：<span class="fr">&yen;<?php echo $goods_arr[0]['order_amount']; ?>&nbsp;&nbsp;
                                    <?php if ($goods_arr[0]['shipping_fee'] > 0){?>
                                    (含<?php echo $goods_arr[0]['shipping_name']?$goods_arr[0]['shipping_name']:'运费';?> &yen;<?php echo $goods_arr[0]['shipping_fee'];?>)
                                    <?php }else{?>
                                    <?php echo '(免运费)';?>
                                    <?php }?>
                                    </span>
                                </p>
                             </div>
                            <?php foreach($goods_arr as $item){?>
                            <a class="new-mu_l2a new-p-re" href="index.php?act=goods&goods_id=<?php echo $item['goods_id']?>">
                                <div class="order-msg">
                                    <img src="<?php echo cthumb($item['goods_image'],'small',$item['store_id'])?>"  onload="javascript:DrawImage(this,90,90);">
                                    <div class="order-msg">
                                        <p class="title"><?php echo $item['goods_name']?></p>
                                        <p class="price">单价：&yen;<?php echo $item['goods_price']?><span></span></p>
                                        <p class="order-data">数量：<?php echo $item['goods_num']?> 件</p>
                                    </div>
                                </div>
                            </a>
                            <?php }?>
                            <div class="order_mod">
                                <div class="pay-order">
                                    <a href="index.php?act=member_order&op=orderDetail&order_id=<?php echo $goods_arr[0]['order_id']; ?>">查看订单</a>
                                </div>
                                <!--查看物流信息-->
                                <?php  if($goods_arr[0]['shipping_mode'] == SHIPPING_MODE_DEFAULT && $goods_arr[0]['shipping_express_id'] > 0) { ?>
                                <div class="pay-order">
                                    <a href="index.php?act=member_order&op=show_express&order_id=<?php echo $goods_arr[0]['order_id']; ?>">查看物流</a>
                                </div>
                                <?php }elseif ($goods_arr[0]['shipping_mode'] == SHIPPING_MODE_MDT || $goods_arr[0]['shipping_mode'] ==SHIPPING_MODE_FDY){
                  					if (empty($goods_arr[0]['shipping_express_id']) && $goods_arr[0]['order_state'] >= 25) {
                       			?>
                                	<div class="pay-order">
                                		<a href='index.php?act=member_order&op=show_express&order_id=<?php echo $goods_arr[0]['order_id']; ?>'>查看物流</a>
                          			</div>
                          			<?php }elseif(!empty($goods_arr[0]['shipping_express_id']) && ($goods_arr[0]['order_state']>=30||$goods_arr[0]['order_state']==11)){?>
                                    <div class="pay-order">
                                        <a href="index.php?act=member_order&op=show_express&order_id=<?php echo $goods_arr[0]['order_id']; ?>">查看物流</a>
                                    </div>
                                <?php 
										}
									}
								?>	
                                <!--申请售后-->
                                <?php
                    				$seven_days = time()-3600*24*ORDER_RETURN_DAY_LIMIT;//判断是否九天内
									//订单是否在规定期限内+订单是否确认收货或者不是货到付款
									if ($goods_arr[0]['add_time']>$seven_days&&(($goods_arr[0]['order_cod']==0&&$goods_arr[0]['order_state'] >=20)||($goods_arr[0]['order_cod']==1&&($goods_arr[0]['order_state'] ==11||$goods_arr[0]['order_state']>=40)))&&$goods_arr[0]['refund_state'] == 0 && $goods_arr[0]['return_state'] == 0) {
								?>
                                <div class="pay-order">
                    				<a href="index.php?act=member_order&op=applysale&order_id=<?php echo $goods_arr[0]['order_id']; ?>">申请售后</a>
                                </div>
								<?php } ?>

                                
                                <!------------------------------售后动态----------------退货退款-------------------------->
                                <?php if($goods_arr[0]['return_state'] > 0 && $goods_arr[0]['refund_state'] > 0){?>
                                <div class="pay-order">
                                    <a href="index.php?act=member_order&op=return_view&return_id=<?php echo $goods_arr[0]['return']['return_id']; ?>&log_id=<?php echo $goods_arr[0]['refund']['log_id']; ?>">售后动态</a>
                                </div>
                                <?php }?>
                                 <!------------------------------售后动态----------------仅退款-------------------------->
                                 <?php if(!$goods_arr[0]['return_state'] > 0 && $goods_arr[0]['refund_state'] > 0){?>
                                <div class="pay-order">
                                    <a href="index.php?act=member_order&op=refund_view&log_id=<?php echo $goods_arr[0]['refund']['log_id']; ?>">售后动态</a>
                                </div>
                                <?php }?>
                                
                                <!--买家确认收货-->
                                <?php if ($goods_arr[0]['refund_state'] == 0 && $goods_arr[0]['order_state'] == 30) { ?>
                                    <?php if ($goods_arr[0]['payment_direct'] == '1'){?>
                                    <div class="pay-order">
                                    	<a href="#!confirm_order" onclick="changeId(<?php echo $goods_arr[0]['order_sn'];?>,<?php echo $goods_arr[0]['order_id']; ?>,1)">确认收货</a>
                                    </div>
                                    <?php }?>
                                <?php } ?>
                                
                                <!--取消订单/付款-->
                                 <?php if ($goods_arr[0]['order_state'] == 10) { ?>
                                <div class="pay-order">
                                	<a href="#!cancel_order" onclick="changeId(<?php echo $goods_arr[0]['order_sn'];?>,<?php echo $goods_arr[0]['order_id']; ?>,0)">取消订单</a>
                                </div>
                                 <?php }?>
                                <?php if ($goods_arr[0]['order_state'] == 10 && $goods_arr[0]['order_cod'] != 1) { ?>
                                <div class="pay-order">
                                    <a href="index.php?act=order&op=order_pay&order_id=<?php echo $goods_arr[0]['order_id']; ?>">付款</a>
                                </div>
                                <?php } ?>

                                <!-- 货到付款订单取消开始-->
                                <?php if(($goods_arr[0]['order_cod'] == 1 && $goods_arr[0]['order_state'] == 15)|| ($goods_arr[0]['order_cod'] == 1 && $goods_arr[0]['order_send'] == 0 && $goods_arr[0]['order_state'] != 0)){?>
                                <div class="pay-order">
                                    <!-- <a href="#!cancel_order" paytype="iscash" onclick="changeCashId(this,<?php echo $goods_arr[0]['order_sn'];?>,<?php echo $goods_arr[0]['order_id']; ?>,0)">取消订单</a> -->
                                    <a href="#!cancel_order" onclick="changeId(<?php echo $goods_arr[0]['order_sn'];?>,<?php echo $goods_arr[0]['order_id']; ?>,0)">取消订单</a>
                                </div>
                                <?php }?>
                                <!-- 货到付款订单取消结束-->
                                
                                <!--评价-->
                                <?php if (($goods_arr[0]['order_state'] == 40) && $goods_arr[0]['refund_state'] < 2 && $goods_arr[0]['able_evaluate']) { ?>
                                <div class="pay-order">
                                	<a href="#!evaluate" onclick="$('#add_eval').attr('action','index.php?act=member_evaluate&op=add&order_id=<?php echo $goods_arr[0]['order_id']?>')">我要评价</a>
                                </div>
                                <?php } ?>
                            </div>
                        </div>
                    </li>
                    <?php }?>
                </ul>
                <?php }else{?>
                <div style="text-align:center;padding:40px;font-size:16px;">抱歉暂时没有相关结果</div>
                <?php }?>
            </section>
        </div>
        
        <div id="paymentp" style="padding:10px; line-height:36px;">
            <a href="javascript:void(0);" onclick="selAll(this);" class="checkbox goods-choose-state" style=" margin:8px 0 0;clear:both" id="selAll"></a>&nbsp;全选&nbsp;&nbsp;
            <a class="btn go-payment" style=" margin:0; font-size:16px; background: rgb(192, 0, 0); display:inline-block" id="hbzf">合并支付</a>
        </div>
        
        <?php include 'page.php';?>
        
    </div>
    
    <div id="cancel_order" style=" padding:15px;-webkit-box-flex: 1;width: 100%; overflow:hidden;display: none!important;">
      <form method="get">
      	<input type="hidden" name="act" value="member_order" />
        <input type="hidden" name="op" value="change_state" />
        <input type="hidden" name="state_type" value="cancel_order" />
        <input type="hidden" name="order_id" id="order_id" value="" />
        <h3>您确定要取消下面的订单吗?</h3>
        <p style="line-height:40px;">订单号：<span id="order_sn"></span></p>
        <dl>
          <dt>取消原因：</dt>
          <dd>
            <ul class="checked">
              <li>
                <input type="radio" checked name="state_info" id="d1" value="改买其它商品" />
                <label for="d1">改买其它商品</label>
              </li>
              <li>
                <input type="radio" name="state_info" id="d2" value="改用其它配送方式" />
                <label for="d2">改用其它配送方式</label>
              </li>
              <li>
                <input type="radio" name="state_info" id="d3" value="从其它商城购买" />
                <label for="d3">从其它商城购买</label>
              </li>
              <li>
                <input type="radio" name="state_info" flag="other_reason" id="d4" value="其它原因" />
                <label for="d4">其它原因</label>
              </li>
              <li id="other_reason" style="display:none;">
                <textarea name="state_info1" rows="2" id="other_reason_input"></textarea>
              </li>
            </ul>
          </dd>
        </dl>
        <dl class="bottom">
          <dt>&nbsp;</dt>
          <input type="submit" class="order_sub" value="确定" />
        </dl>
        </form>
	</div>
    
    <div id="confirm_order" style=" padding:15px;-webkit-box-flex: 1;width: 100%; overflow:hidden;display: none!important;">
    	<form  method="get" >
        <input type="hidden" name="act" value="member_order" />
        <input type="hidden" name="op" value="change_state" />
        <input type="hidden" name="state_type" value="confirm_order" />
        <input type="hidden" name="order_id" id="order_id_t" value="" />
        <h3>您是否确认已收到以下订单的商品?</h3>
        <p style="line-height:40px;">订单号：<span id="order_sn_t"></span></p>
        <dl>
          <p class="hint pl10 pr10">请注意： 如果你尚未收到商品请不要点击“确定”。大部分被骗案件都是由于提前确认付款被骗的，请谨慎操作！</p>
        </dl>
        <dl class="bottom">
          <dt>&nbsp;</dt>
          <dd>
            <input type="submit" class="order_sub" value="确定" />
          </dd>
        </dl>
      </form>
    </div>
    
    <div id="evaluate" style=" padding:2px 10px; -webkit-box-flex: 1;width: 100%; overflow:hidden;display: none!important;">
      <form id="add_eval" method="post" action="">
        <div class="eval_tit">交易评价</div>
        <dl>
              <dt>卖家的产品品质：</dt>
              <dd>
                  <ul>
                      <li class="tooltip" title="很好">
                          <input name="store[goodsquality]" type="radio" id="goodsquality_1" value="100" checked="checked">
                          <label for="goodsquality_1"class="rate-star"> <em style="margin-top:3px;"><i style=" width:100%;"></i></em>
                              (很好) </label>
                      </li>
                      <li class="tooltip" title="好">
                          <input id="goodsquality_2" type="radio" value="80" name="store[goodsquality]">
                          <label for="goodsquality_2" class="rate-star"> <em style="margin-top:3px;"><i style=" width:80%;"></i></em>
                              (好)</label>
                      </li>
                      <li class="tooltip" title="一般">
                          <input id="goodsquality_3" type="radio" value="60" name="store[goodsquality]">
                          <label for="goodsquality_3" class="rate-star"> <em style="margin-top:3px;"><i style=" width:60%;"></i></em>
                              (一般) </label>
                      </li>
                  </ul>
              </dd>
          </dl>

          <dl>
              <dt>产品的包装品质：</dt>
              <dd>
                  <ul>
                      <li class="tooltip" title="很好">
                          <input name="store[packagequality]" type="radio" id="packagequality_1" value="100" checked="checked">
                          <label for="packagequality_1" class="rate-star"><em style="margin-top:3px;"><i style="width:100%;"></i></em>
                              (很好)</label>
                      </li>
                      <li class="tooltip" title="好">
                          <input id="packagequality_2" type="radio" value="80" name="store[packagequality]">
                          <label for="packagequality_2" class="rate-star"> <em style="margin-top:3px;"><i style=" width:80%;"></i></em>
                              (好)</label>
                      </li>
                      <li class="tooltip" title="一般">
                          <input id="packagequality_3" type="radio" value="60" name="store[packagequality]">
                          <label for="packagequality_3" class="rate-star"> <em style="margin-top:3px;"><i style=" width:60%;"></i></em>
                              (一般)</label>
                      </li>
                  </ul>
              </dd>
          </dl>

        <dl>
          <dt>卖家的发货速度：</dt>
          <dd>
            <ul>
              <li class="tooltip" title="很快">
                <input name="store[shippingspeed]" type="radio" id="shippingspeed_1" value="100" checked="checked">
                <label for="shippingspeed_1" class="rate-star"> <em style="margin-top:3px;"><i style=" width:100%;"></i></em>
                    (很好)</label>
              </li>
              <li class="tooltip" title="好">
                <input id="shippingspeed_2" type="radio" value="80" name="store[shippingspeed]">
                <label for="shippingspeed_2" class="rate-star"> <em style="margin-top:3px;"><i style=" width:80%;"></i></em>
                    (好)</label>
              </li>
              <li class="tooltip" title="一般">
                <input id="shippingspeed_3" type="radio" value="60" name="store[shippingspeed]">
                <label for="shippingspeed_3" class="rate-star"> <em style="margin-top:3px;"><i style=" width:60%;"></i></em>
                    (一般)</label>
              </li>
            </ul>
          </dd>
        </dl>
        
          <dl>
              <dt>卖家的售后服务：</dt>
              <dd>
                  <ul>
                      <li class="tooltip" title="很好">
                          <input name="store[aftersale]" type="radio" id="aftersale_1" value="100" checked="checked">
                          <label for="aftersale_1" class="rate-star"> <em style="margin-top:3px;"><i style=" width:100%;"></i></em>
                              (很好)</label>
                      </li>
                      <li class="tooltip" title="好">
                          <input id="aftersale_2" type="radio" value="80" name="store[aftersale]">
                          <label for="aftersale_2" class="rate-star"> <em style="margin-top:3px;"><i style=" width:80%;"></i></em>
                              (好)</label>
                      </li>
                      <li class="tooltip" title="一般">
                          <input id="aftersale_3" type="radio" value="60" name="store[aftersale]">
                          <label for="aftersale_3" class="rate-star"> <em style="margin-top:3px;"><i style=" width:60%;"></i></em>
                              (一般)</label>
                      </li>
                  </ul>
              </dd>
          </dl>
          
        <dl class="bottom">
          <dt>&nbsp;</dt>
          <input type="submit" class="order_sub" value="确定" />
        </dl>
        </form>
	</div>
</div>

<script type="text/javascript">
$('#state_type').change(function(){
	$('#st').val($(this).val());
})

function changeId(order_sn,order_id,type){
	if(type == 0){
		$('#order_sn').html(order_sn);
		$('#order_id').val(order_id);
	}else if(type == 1){
		$('#order_sn_t').html(order_sn);
		$('#order_id_t').val(order_id);
	}
}

$(function(){
   $("input[name='state_info']").click(function(){
		if ($(this).attr('flag') == 'other_reason')
		{
			$('#other_reason').show();
		}
		else
		{
			$('#other_reason').hide();
		}
	});
});
	
(function(){
	selChange=function (obj) {
    	if($(obj).hasClass('checked')){
			$(obj).removeClass('checked');
		}else{
			$(obj).addClass('checked');
		}
    }
	selAll = function(obj){
		if($(obj).hasClass('checked')){
			$('.checkbox').removeClass('checked');
		}else{
			$('.checkbox').addClass('checked');
		}
	}
    $(document).ready(function (e) {
		$('#hbzf').click(function(){
			var url = 'index.php?act=order&op=order_pay';
			var order_id = '';
			$(".checkbox").each(function () {
				if ($(this).hasClass('checked') && $(this).data('order_id') != 'undefined' && $(this).data('order_id') != null) {
					order_id += '&order_id[]=' + $(this).data('order_id');
				}
			});
			window.location = url + order_id;
		});
    });
})();
</script>
